package day09;

import java.util.Objects;

public class Student {
    private  int id;
    private  String sno;
    private  int age;



    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Student{");
        sb.append("id=").append(id);
        sb.append(", sno='").append(sno).append('\'');
        sb.append(", age=").append(age);
        sb.append('}');
        return sb.toString();
    }

    public Student(int id, String sno, int age) {
        this.id = id;
        this.sno = sno;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public  boolean equals(Object obj){
//非空性

        if (obj == null){
            return  false;
        }
        //自反性
        if (this==obj){
            return true;
        }
        //一致性-重点-到底是根据那个属性来判断
        //需求一
        if(obj instanceof  Student){
            Student s=(Student)obj;
            if (this.id==s.getId()){
                return  true;
            }
        }
        return false;
    }
}
